package com.egene.tw.activity.member;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.egene.tw.R;
import com.egene.tw.base.BaseActivity;
import com.egene.tw.dao.UserDao;
import com.egene.tw.network.ApiConstant;
import com.egene.tw.utils.NetworkUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_about_me)
public class HealthPunchActivity extends BaseActivity {
    //ToolBar Views
    @ViewById(R.id.actionBar)
    Toolbar mToolbarView;
    @ViewById(R.id.toolbar_title)
    TextView mToolBarTitle;


    @ViewById
    WebView wvAboutMe;

    @Bean
    UserDao userDao;

    @AfterViews
    void initViews(){
        initToolBar();

        wvAboutMe.loadUrl(ApiConstant.BASE_URL + "/admin/ques/app_first_quest.aspx?userid=" + userDao.getUser().getUserID());
//        wvAboutMe.loadUrl(ApiConstant.BASE_URL + "/admin/ques/app_new.aspx?userid=" + userDao.getUser().getUserID());
        wvAboutMe.getSettings().setJavaScriptEnabled(true);
        wvAboutMe.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                if(NetworkUtil.isNetworkConnected()){
                    wvAboutMe.setVisibility(View.VISIBLE);
                }else{
                    wvAboutMe.setVisibility(View.GONE);
                }
            }
        });
    }

    private void initToolBar() {
        mToolBarTitle.setText(R.string.health_punch);
        mToolbarView.setNavigationIcon(R.drawable.ic_back);
        mToolbarView.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}